package state

import (
	"../base"
	"sync"
	"time"
)

const (
	PeerStateLeader uint8 = 0
)

var (
	SelfState uint = 0

	TickTime  uint = 2000
	ValidTime uint = 3000

	Locker sync.Mutex
	Uptime time.Time

	KeeperId   string
	KeeperName string

	//Leader Peer
	Leader     *Peer
	PeerLocker sync.Mutex
	PeerIds    []string
	Peers      map[string]*Peer
	PeersDiff  string
)

type Peer struct {
	base.Peer
	Url string `json:"url"`
}

func Initialize() error {

	Uptime = time.Now()

	Leader = &Peer{}
	PeerIds = []string{}
	Peers = map[string]*Peer{}

	return nil
}
